coreutils: Protect against env -a for security#10773
coreutils: Protect against env -a for security#10773Ecordonnier merged 3 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
01b6655 to
753f86c
Compare
|
GNU testsuite comparison: |
Merging this PR will not alter performance
Comparing Footnotes
|
59e307c to
ac75ff7
Compare
|
GNU testsuite comparison: |
|
I think it would make sense for this code to go into the validation.rs file instead of in the main.rs, then you don't have to worry about importing libc. It would be good to have an additional integration test that shows the env -a working |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
1337cbc to
40581ee
Compare
|
GNU testsuite comparison: |
a5dd042 to
526f6fc
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Co-authored-by: Etienne Cordonnier <ecordonnier@snap.com>
c54b52f to
2d60946
Compare
|
GNU testsuite comparison: |
|
is this ok? |
|
@Ecordonnier ok? |
|
GNU testsuite comparison: |
yes, sorry for the delay |
|
Btw, this is not only a security fix. For instance there is a bug in Cursor which is packaged using AppImage: The integrated terminal of cursor starts uutils-coreutils with a wrong value of arv[0]. See https://forum.cursor.com/t/argv-0-is-replaced-with-cursor-bin-appimage/44878 This is explained here: So this PR should fix this issue. |
|
I think AppImage should support AT_EXECFN instead, but fixing it at here is not too bad. |
|
@Ecordonnier Can we mix raw and libc backends or directly use raw's execfn function? We might switch to libc backend for LD_PRELOAD GnuTests. |
This prevents an attacker from spoofing argv[0] to bypass apparmor restrictions. - `env -a false ls` now correctly runs `ls` instead of dispatching as `false` - Also works under masked `/proc` (does not rely on /proc/self/exe). Closes uutils#10135
I think we can mix if there is a functional need for it. Maybe we should add a test verifying that the program name can't be spoofed using LD_PRELOAD and intercepting libc getauxval(). |
|
I don't know about AppArmor, but is LD_PRELOAD still allowed.
instead of getting permission to do that. |
|
Apparmor does not prevent the usage of LD_PRELOAD. "Also I wanted to know how to directly use raw's execfn" What do you mean? The rustix code shows how the linux syscall is used. |
|
something like rustix::raw::param::linux_execfn() or rustix::use-libc::param::linux_execfn() |
Oh ok, I understand what you mean. I'm not sure that the crate exposes those functions directly. Normally the backend is selected via configuration. |
|
maybe, by removing |
env -a false lsdoes not fail. Works under masked/proc.Closes #10135